package com.freesky.web.portal.controller;

import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.common.vo.VOCart;
import com.freesky.common.vo.CartItem;
import com.freesky.common.pojo.Result;
import com.freesky.web.portal.reomte.CartRemote;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Freesky
 */
@RestController
@Api(description = "购物车")
public class CartController {

    @Autowired
    private CartRemote cartRemote;

    @PostMapping(value = "/member/addCart")
    @ApiOperation(value = "添加购物车商品")
    public JSONResponse addCart(@RequestBody VOCart cart){
        return cartRemote.addCart(cart);
    }

    @PostMapping(value = "/member/cartList")
    @ApiOperation(value = "获取购物车商品列表")
    public JSONResponse getCartList(@RequestBody VOCart cart){
        return cartRemote.getCartList(cart);
    }

    @PostMapping(value = "/member/cartEdit")
    @ApiOperation(value = "编辑购物车商品")
    public JSONResponse updateCartNum(@RequestBody VOCart cart){
        return cartRemote.updateCartNum(cart);
    }

    @PostMapping(value = "/member/editCheckAll")
    @ApiOperation(value = "是否全选购物车商品")
    public JSONResponse editCheckAll(@RequestBody VOCart cart){
        return cartRemote.editCheckAll(cart);
    }

    @PostMapping(value = "/member/cartDel")
    @ApiOperation(value = "删除购物车商品")
    public JSONResponse deleteCartItem(@RequestBody VOCart cart){
        return cartRemote.deleteCartItem(cart);
    }

    @PostMapping(value = "/member/delCartChecked")
    @ApiOperation(value = "删除购物车选中商品")
    public JSONResponse delChecked(@RequestBody VOCart cart){
        return cartRemote.deleteCartItem(cart);
    }
}
